﻿#include <iostream>
using namespace std;

class Component
{
public:
	Component(){}
	virtual ~Component(){}

	virtual void Operation() = 0;
};

class ConcreteComponent:public Component
{
public:
	ConcreteComponent(){}
	virtual ~ConcreteComponent(){}

	void Operation()
	{
		cout << "ConcreateComponent operation" << endl;
	}
};

class Decorator
{
public:
	virtual ~Decorator(){}

	virtual void Operation() = 0;
	virtual void AddBehavior() = 0;
};

class ConcreteDecorator :public Decorator
{
public:
	ConcreteDecorator(Component * com)
	{
		m_com = com;
	}

	virtual ~ConcreteDecorator()
	{
		delete m_com;
	}

	void AddBehavior()
	{
		cout << "ConcreteDecorator add behavior" << endl;
	}

	void Operation()
	{
		cout << "ConcreteDecorator opration" << endl;
		AddBehavior();
		m_com->Operation();
	}


private:
	Component* m_com;
};

int main()
{
	ConcreteComponent* comp = new ConcreteComponent();
	ConcreteDecorator* decorator = new ConcreteDecorator(comp);
	
	decorator->Operation();

	delete decorator;
	return 0;
}

